/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.panpf.sketch.sample;

import me.panpf.sketch.sample.util.FileUtils;
import me.panpf.sketch.sample.util.PxUtil;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import org.junit.Assert;
import org.junit.Test;

/**
 * 单元测试
 */
public class ExampleOhosTest {
    Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    /**
     * PxUtil_fp2px
     */
    @Test
    public void PxUtil_fp2px() {
        PxUtil.initContext(context);
        float pxTurn = PxUtil.fp2px(15);
        Assert.assertEquals(45.5, pxTurn, 0.0);
    }

    /**
     * PxUtil_vp2px
     */
    @Test
    public void PxUtil_vp2px() {
        PxUtil.initContext(context);
        float pxTurn = PxUtil.vp2px(15);
        Assert.assertEquals(45.5, pxTurn, 0.0);
    }

    /**
     * PxUtil_screenWidth
     */
    @Test
    public void PxUtil_screenWidth() {
        PxUtil.initContext(context);
        int width = PxUtil.screenWidth();
        Assert.assertTrue(width > 0);
    }

    /**
     * PxUtil_screenHeight
     */
    @Test
    public void PxUtil_screenHeight() {
        PxUtil.initContext(context);
        int height = PxUtil.screenHeight();
        Assert.assertTrue(height > 0);
    }

    /**
     * FileUtil_formatFileSizeKB
     */
    @Test
    public void FileUtil_formatFileSizeKB() {
        String size = FileUtils.formetFileSize(200000);
        Assert.assertEquals("200.00KB",size);
    }

    /**
     * FileUtil_formatFileSizeMB
     */
    @Test
    public void FileUtil_formatFileSizeMB() {
        String size = FileUtils.formetFileSize(200000000);
        Assert.assertEquals("200.00MB",size);
    }

    /**
     * FileUtil_formatFileSizeGB
     */
    @Test
    public void FileUtil_formatFileSizeGB() {
        String size = FileUtils.formetFileSize(2000000000);
        Assert.assertEquals("2.00GB",size);
    }
}